package net.ipinglun.fragments;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import net.ipinglun.R;

public class NewsCardFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {


    private int mChannelId;
    private Context mContext;
    private Activity mActivity;



    private SwipeRefreshLayout mSwipeLayout;


    public static NewsCardFragment newInstance(int channelId) {

        NewsCardFragment fragment = new NewsCardFragment();
        Bundle args = new Bundle();
        args.putInt("channelId", channelId);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        Bundle arg = getArguments();
        mChannelId = arg.getInt("channelId");
        mContext = getActivity();
        mActivity = getActivity();
        return inflater.inflate(R.layout.fragment_news, container, false);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        mSwipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh);
        mSwipeLayout.setProgressViewOffset(false, 0, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics()));

        mSwipeLayout.setOnRefreshListener(this);
        mSwipeLayout.setColorScheme(R.color.main_color, android.R.color.holo_green_light,
                android.R.color.holo_orange_light, android.R.color.holo_blue_light);


    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);


    }

    public void onRefresh() {

    }

}
